<?php   // $Id: dep_edit.php 251 2008-08-04 22:02:16Z pcoustillas $ ?>
<?php   
/*Copyright (C) 2003-2004 Guy Hendrickx
Licensed under the terms of the GNU  General Public License:http://www.opensource.org/licenses/gpl-license.php
File Authors:Guy Hendrickx
Modification : Pierre Coustillas*/

require_once("include/verif.php");
require_once("include/config/common.php");
require_once("include/headers.php");

require_once("include/head.php");

$num_dep=isset($_GET['num_dep'])?$_GET['num_dep']:"";

?>
<script language="javascript" src="javascripts/verifier_form.js" type="text/javascript"></script>
<script type="text/javascript">
	function verif_modif_dep()
	{
		if (verifier('depense','black','date','vide#date_','lib','vide','prix','vide#est_nombre','four','vide'))
		{
			document.depense.submit();
		} else {
			alert("<?php aff_lang('Une des valeurs saisie n\'est pas correct.\nMerci de corriger avant de poursuivre.') ?>")	
		}

	}
</script>

<table class="page" align="center">
	<tr>
		<td class="page" align="center" >
			<?php
			require_once("include/head.php");
			?>
		</td>
	</tr>
	<tr>
		<td class="page" align="center">
			<?php

			if ($user_dep == "n") { 
			echo "<h1>$lang_depense_droit</h1>";
			exit;
			}

			if (isset($_GET['message']))
			{
				echo "<h1>" . stripslashes($_GET['message']) . "</h1>";
			}

			$sql = "SELECT * FROM ${tblpref}depense WHERE num=$num_dep";
			$req = mysql_query($sql) or die("Erreur seelction dépense !<br/>$sql<br>" . mysql_error());
			while($data = mysql_fetch_array($req))
			{
				$num = $data['num'];
				$prix = $data['prix'];
				$date = sql_to_date($data['date']);
				$lib = htmlentities($data['lib'], ENT_QUOTES,'UTF-8');
				$four = htmlentities($data['fournisseur'], ENT_QUOTES,'UTF-8');
				//$four = stripslashes($four);
			}
		?>
			<center>
			<br/><br/>

			<form name="depense" method="post" action="dep_edit_suite.php">
				<input name="num" type="hidden" value="<?php echo "$num" ?>" />
				<table width="50%">
					<caption>
						<?php aff_lang("Modifier une dépense") ?>
					</caption>
					<tr>
						<td colspan="2">
							<br/><br/>
						</td>
					</tr>
					<tr>
						<td width="50%" id="lib"><?php aff_lang("Libellé") ?></td>
						<td width="50%"><input name="lib" type="text" value="<?php echo "$lib" ?>" /></td>
					</tr>
					<tr>
						<td id="prix"><?php aff_lang("Montant HT")?></td>
						<td><input name="prix" type="text" value="<?php echo "$prix" ?>" /></td>
					</tr>
					<tr>
						<td id="four"><?php aff_lang("Fournisseur") ?></td>
						<td><input name="four" type="text" value="<?php echo "$four" ?>" /></td>
					</tr>
					<tr>
						<td id="date"><?php aff_lang("Date") ?></td>
						<td>
							<input name="date" type="text" size="15" value="<?php echo "$date" ?>" />
							<a href="#" onclick="window.open('include/pop.calendrier.php?frm=depense&amp;ch=date','calendrier','width=415,height=160,scrollbars=0').focus();"><img src="image/petit_calendrier.gif" alt="calendrier" border="0"/></a>
						</td>
					</tr>
					<tr>
						<td colspan="2">
							<br/><br/>
						</td>
					</tr>
					<tr>
						<td class="submit" colspan="2">
							<input type="button" onclick="verif_modif_dep()" value="  Modifier  "/>
						</td>
					</tr>
				</table>
			</form>
			</center>
		</td>
	</tr>
	<tr>
		<td>
			<?php
			require_once("include/bas.php");
			?>
		</td>
	</tr>

</table>
</body>
</html>
